package com.sc.nft.dao;

import com.sc.nft.entity.PayOrder;
import com.sc.nft.enums.PayTypeEnum;
import com.sc.nft.enums.SecondPayOrderItemTypeEnum;
import lombok.extern.slf4j.Slf4j;
import com.sc.nft.entity.PayOrderItem;
import com.sc.nft.mapper.PayOrderItemMapper;
import  com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import org.springframework.stereotype.Repository;

import java.util.List;

/**
 * 支付订单子项表(sc_pay_order_item)数据DAO
 *
 * @author zxy
 * @since 2023-06-14 17:38:47
 * @description 支付订单子项表
 */
@Slf4j
@Repository
public class PayOrderItemDao extends ServiceImpl<PayOrderItemMapper, PayOrderItem> {

    public List<PayOrderItem> getByPayOrderId(Long payOrderId){
        return lambdaQuery().eq(PayOrderItem::getPayOrderId,payOrderId).list();
    }

    public PayOrderItem getByOrderId(Long orderId, SecondPayOrderItemTypeEnum orderType){
        return lambdaQuery().eq(PayOrderItem::getOrderId,orderId).eq(PayOrderItem::getOrderType,orderType).one();
    }

    public PayOrder getByOrderIdAndType(Long orderId, SecondPayOrderItemTypeEnum orderType, PayTypeEnum payTypeEnum){
        return this.baseMapper.getByOrderIdAndOrderType(orderId,orderType,payTypeEnum);
    }

}
